<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 删除数组中所有的偶数。

        // var nums = [2, 4, 5, 6, 7, 9, 2, 3, 1, 6, 14,20,21];
        // var res = nums.filter(function (element) {
        //         return element% 2 != 0;
        // });
        // console.log(res);
        // document.write(res);
// ==============================================================
        function isEven(n) {
            if(n%2==0){
                return true;
            }
            return false;

        }
        var arr = [2, 4, 5, 6, 7, 9, 2, 3, 1, 6, 14,20,21];
        for(var i=0;i<arr.length;i++){
            var num = arr[i];
            if(isEven(num)){
                arr.splice(i,1);
                i--;
            }
        }
    </script>
</body>

</html>